<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2022-12-9:高度塌陷终极解决方式</title>
    <style>
        .box1{
            border:10px red solid;
            /*解决高度塌陷问题:方式1*/
            overflow:hidden;

        }
        .box2{
            width:100px;
            height:200px;
            background-color: #bfa;
            /*导致box2高度塌陷问题*/
            /* float:left; */
        }

        /* .box3{
            clear:both;
        } */
        /* 方式3 */
        .box1::after{
            display:block;
            clear:both;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2"></div>
        <!--添加box3子元素可以撑起父元素box1的高度，可以解决高度塌陷问题：方式2-->
        <!-- <div class="box3"></div> -->
    </div>
    
</body>
</html>
